package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderInvoice;
import com.ktgj.flight.service.IFlightOrderInvoiceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票订单发票Controller
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@RestController
@RequestMapping("/flightOrderInvoice")
public class FlightOrderInvoiceController extends BaseController
{
    @Autowired
    private IFlightOrderInvoiceService flightOrderInvoiceService;

    /**
     * 查询机票订单发票列表
     */
    @PreAuthorize(hasPermi = "flight:invoice:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderInvoice flightOrderInvoice)
    {
        startPage();
        List<FlightOrderInvoice> list = flightOrderInvoiceService.selectFlightOrderInvoiceList(flightOrderInvoice);
        return getDataTable(list);
    }

    /**
     * 导出机票订单发票列表
     */
    @PreAuthorize(hasPermi = "flight:invoice:export")
    @Log(title = "机票订单发票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderInvoice flightOrderInvoice) throws IOException
    {
        List<FlightOrderInvoice> list = flightOrderInvoiceService.selectFlightOrderInvoiceList(flightOrderInvoice);
        ExcelUtil<FlightOrderInvoice> util = new ExcelUtil<FlightOrderInvoice>(FlightOrderInvoice.class);
        util.exportExcel(response, list, "机票订单发票数据");
    }

    /**
     * 获取机票订单发票详细信息
     */
    @PreAuthorize(hasPermi = "flight:invoice:query")
    @GetMapping(value = "/{invoiceId}")
    public AjaxResult getInfo(@PathVariable("invoiceId") Long invoiceId)
    {
        return AjaxResult.success(flightOrderInvoiceService.selectFlightOrderInvoiceById(invoiceId));
    }

    /**
     * 新增机票订单发票
     */
    @PreAuthorize(hasPermi = "flight:invoice:add")
    @Log(title = "机票订单发票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderInvoice flightOrderInvoice)
    {
        return toAjax(flightOrderInvoiceService.insertFlightOrderInvoice(flightOrderInvoice));
    }

    /**
     * 修改机票订单发票
     */
    @PreAuthorize(hasPermi = "flight:invoice:edit")
    @Log(title = "机票订单发票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderInvoice flightOrderInvoice)
    {
        return toAjax(flightOrderInvoiceService.updateFlightOrderInvoice(flightOrderInvoice));
    }

    /**
     * 删除机票订单发票
     */
    @PreAuthorize(hasPermi = "flight:invoice:remove")
    @Log(title = "机票订单发票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{invoiceIds}")
    public AjaxResult remove(@PathVariable Long[] invoiceIds)
    {
        return toAjax(flightOrderInvoiceService.deleteFlightOrderInvoiceByIds(invoiceIds));
    }
}
